package cn.johnyu.controller;

import cn.johnyu.pojo.Product;
import cn.johnyu.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
//rest=http+json
@CrossOrigin
@RestController
public class ProductController {
    @Autowired
    private ProductService productService;
    @PostMapping("/products")
   public  Product addProduct(@RequestBody Product product){
        return productService.addProduct(product);
    }
}
